### Project 9 RGB LED ![](media/image-20251121165840096.png) **1. Introduction:** Tricolor principle to display various colors;PWM controlling ports to display full color;Can be driven directly by Arduino PWM interfaces. ![](media/image-20251121165920580.png) **2. Hardware Required:** - Arduino controller × 1 - USB cable × 1 - Full-color LED module × 1 **3. Connection for REV4** ![](media/image-20251121165953455.png) **4. Connection for 2560 R3** ![](media/image-20251121170153790.png) **5. Sample Code** ```c int redpin = 11; //select the pin for the red LED int bluepin =10; // select the pin for the blue LED int greenpin =9;// select the pin for the green LED int val; void setup() { pinMode(redpin, OUTPUT); pinMode(bluepin, OUTPUT); pinMode(greenpin, OUTPUT); Serial.begin(9600); } void loop() { for(val=255; val>0; val--) { analogWrite(11, val); analogWrite(10, 255-val); analogWrite(9, 128-val); delay(1); } for(val=0; val<255; val++) { analogWrite(11, val); analogWrite(10, 255-val); analogWrite(9, 128-val); delay(1); } Serial.println(val, DEC); } ``` **Result:** Directly copy the above code into arduino IDE, and click upload![](media/6.png),wait for a few seconds, you can see a full-color LED. ![](media/image-20251121170358560.png)